﻿<%@ Page Title="" Language="C#" MasterPageFile="~/Site.master" AutoEventWireup="true"
    CodeFile="ABMDispositivo.aspx.cs" Inherits="Intranet_ABMDispositivo" %>

<asp:Content ID="Content1" ContentPlaceHolderID="HeadContent" runat="Server">
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="MainContent" runat="Server">
    <div class="buttoncontainer" style="clear: both">
        <asp:LinkButton ID="cmdNuevo" runat="server" OnClick="cmdNuevo_Click" CssClass="button">Nuevo Dispositivo</asp:LinkButton>
    </div>
    <br />
    <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
        <ContentTemplate>
            <asp:GridView ID="grd" runat="server" OnRowCommand="grd_RowCommand" AutoGenerateColumns="False"
                Width="100%">
                <Columns>
                    <asp:BoundField DataField="TipoDispositivo" HeaderText="Tipo">
                        <HeaderStyle HorizontalAlign="Left" />
                        <ItemStyle Width="10%" />
                    </asp:BoundField>
                    <asp:BoundField DataField="Descripcion" HeaderText="Descripcion">
                        <HeaderStyle HorizontalAlign="Left" />
                        <ItemStyle Width="20%" />
                    </asp:BoundField>
                    <asp:BoundField DataField="IMEI" HeaderText="IMEI">
                        <HeaderStyle HorizontalAlign="Left" />
                        <ItemStyle Width="15%" />
                    </asp:BoundField>
                    <asp:BoundField DataField="NroSerie" HeaderText="NroSerie">
                        <HeaderStyle HorizontalAlign="Left" />
                        <ItemStyle Width="15%" />
                    </asp:BoundField>
                    <asp:BoundField DataField="NroCelular" HeaderText="NroCelular">
                        <HeaderStyle HorizontalAlign="Left" />
                        <ItemStyle Width="10%" />
                    </asp:BoundField>
                    <asp:TemplateField HeaderText="Activo">
                        <ItemTemplate>
                            <asp:Label ID="Label1" runat="server" 
                                Text='<%# obtenerEstado (Eval("Activo")) %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:BoundField DataField="Vehiculo" HeaderText="Vehiculo">
                        <HeaderStyle HorizontalAlign="Left" />
                    </asp:BoundField>
                    <asp:ButtonField CommandName="modificar" Text="Modificar" ButtonType="Image" ImageUrl="~/Graphics/editar20.png">
                        <ItemStyle Width="1px" />
                    </asp:ButtonField>
                </Columns>
                <EmptyDataTemplate>
                    <asp:Label ID="Label1" runat="server" 
                        Text='<%# obtenerEstado (Eval("Activo")) %>'></asp:Label>
                </EmptyDataTemplate>
            </asp:GridView>
            <div id="dialog" style="display: none" title="">
                <div id="c1" style="width: 150px; float: left;">
                    Tipo:
                </div>
                <div id="v1">
                    <asp:DropDownList ID="cmbTipo" runat="server">
                    </asp:DropDownList>
                </div>
                <div style="width: 150px; float: left; height: 15px;">
                    Vehiculo:
                </div>
                <div>
                    <asp:DropDownList ID="cmbVehiculo" runat="server">
                    </asp:DropDownList>
                </div>
                <div id="c2" style="width: 150px; float: left;">
                    Descripción:
                </div>
                <div id="v2">
                    <asp:TextBox ID="txtDescripcion" runat="server" MaxLength="80" Width="360px"></asp:TextBox>
                </div>
                <div id="c3" style="width: 150px; float: left;">
                    IMEI:
                </div>
                <div id="v3">
                    <asp:TextBox ID="txtIMEI" runat="server" MaxLength="15" Width="116px"></asp:TextBox>
                </div>
                <div id="c4" style="width: 150px; float: left;">
                    Nro. Serie:
                </div>
                <div id="v4">
                    <asp:TextBox ID="txtNroSerie" runat="server" MaxLength="20" Width="150px"></asp:TextBox>
                </div>
                <div id="c5" style="width: 150px; float: left;">
                    Nro. Celular:
                </div>
                <div id="v5">
                    <asp:TextBox ID="txtNroCelular" runat="server" MaxLength="20" Width="150px"></asp:TextBox>
                </div>
                <div id="c6" style="width: 150px; float: left;">
                    Activo:
                </div>
                <div id="v6">
                    <asp:CheckBox ID="chkActivo" runat="server" Text="Activo" />
                </div>
                <div id="c7" style="width: 320px; float: left; margin-top: 10px">
                    * Datos requeridos
                </div>
                <div id="botones" style="text-align: right;">
                    <br />
                    <asp:LinkButton ID="cmdAceptar" runat="server" CssClass="button" OnClick="cmdAceptar_Click"
                        ValidationGroup="abm">Aceptar</asp:LinkButton>
                    <asp:LinkButton ID="cmdCancelar" runat="server" CssClass="button" OnClientClick="HideDialog(); return false;">Cancelar</asp:LinkButton>
                </div>
            </div>
            <input type="hidden" name="title" id="hidTitle" value="" runat="server" />
        </ContentTemplate>
        <Triggers>
            <asp:AsyncPostBackTrigger ControlID="cmdNuevo" EventName="Click" />
        </Triggers>
    </asp:UpdatePanel>
    <script>
        function ShowDialog(titulo) {
            $("#dialog").dialog({ modal: true, width: 550, resizable: false, title: titulo }).parent().appendTo(jQuery("form:first"));
        }
        function HideDialog() {
            $(".ui-dialog-titlebar-close").click();
        }
        var prm = Sys.WebForms.PageRequestManager.getInstance();

        prm.add_endRequest(EndRequest);

        function EndRequest(sender, args) {
            ShowDialog($("#<%=hidTitle.ClientID %>").val());
        }
    </script>
</asp:Content>
